﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entity;
using BAL;
using Common;
using System.Text;
using System.Web.UI.DataVisualization.Charting;
using System.Text.RegularExpressions;

namespace Web
{
    public partial class SchoolChartPrint2 : System.Web.UI.Page
    {
        //SchoolChartMain
        protected int examroomid = 0, schoolid = 0;
        protected string ExamRoomId = "";
        protected string AreaName = "", SchoolName = "";
        //SchoolChartBase
        //SchoolChartQuest
        //SchoolChartKnowModle
        //SchoolChartKnowPoint
        //SchoolChartCongitive
        //SchoolChartQuestType
        //SchoolChartDiffic
        //SchoolChartAnswer
        //SchoolChartEnd
        //提取的公用中间变量
        ExamRoomInfo examroomInfo = null;
        SchoolInfo schoolInfo = null;
        IList<int> gradeIds = null;
        IList<TClassInfo> classInfos = null;
        IList<StudentScoreExtendInfo> studentscoreinfos = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!UserValidate.CheckLogin(this.Request, "StatistScore"))
            {
                Response.Write("<script type=\"text/javascript\">top.location.href='login.aspx';</script>");
                Response.Redirect("login.aspx");
                Response.End();
            }
            if (!PageValidate.QueryStringIsEmpty("schoolid"))
            {
                try
                {
                    schoolid = int.Parse(PageValidate.QueryString("schoolid"));
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                    Response.End();
                }
            }
            if (!PageValidate.QueryStringIsEmpty("examroomid"))
            {
                try
                {
                    examroomid = int.Parse(PageValidate.QueryString("examroomid"));
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                    Response.End();
                }
            }
            if (!IsPostBack)
            {
                if (examroomid > 0 && schoolid > 0)
                {
                    examroomInfo = ExamRoom.GetSingleInfo(examroomid);
                    schoolInfo = School.GetSingleInfo(schoolid);
                    if (examroomInfo != null && schoolInfo != null)
                    {
                        SchoolChartMain(examroomInfo, schoolInfo);
                        SchoolChartBase();
                        SchoolChartQuest();
                        SchoolChartKnowModle();
                        SchoolChartKnowPoint();
                        SchoolChartCongitive();
                        SchoolChartQuestType();
                        SchoolChartDiffic();
                        SchoolChartAnswer();
                    }
                    else
                    {
                        Response.Redirect("AdminExamRoom.aspx");
                    }
                }
                else
                {
                    Response.Redirect("AdminExamRoom.aspx");
                }
            }
        }
        #region SchoolChartMain
        private void SchoolChartMain(ExamRoomInfo examroominfo, SchoolInfo schoolInfo)
        {
            SchoolName = schoolInfo.Name;
            AreaName = schoolInfo.AreaName;
            ExamRoomId = examroominfo.CreateDate.ToShortDateString() + "-" + examroominfo.Id.ToString();
        }
        #endregion
        #region SchoolChartBase
        private void SchoolChartBase()
        {
            StringBuilder sb = new StringBuilder();
            StringBuilder gsb = new StringBuilder();
            gradeIds = Grade.GetGradeIdBySchoolId(schoolid);
            classInfos = TClass.GetClassInfoByGradeId(gradeIds);
            studentscoreinfos = new List<StudentScoreExtendInfo>();
            studentscoreinfos = StudentScoreExtend.GetList(examroomid, 0, schoolid, 0, 0, 0, 0, 0);

            IList<int> goodNum = GoodSchoolScoreSort(studentscoreinfos);
            IList<int> midNum = MidSchoolScoreSort(studentscoreinfos);
            IList<int> lowNum = LowSchoolScoreSort(studentscoreinfos);
            IList<int> endNum = EndSchoolScoreSort(studentscoreinfos);

            int num = 1;
            foreach (TClassInfo classInfo in classInfos)
            {
                IList<StudentScoreExtendInfo> classscoreInfos = studentscoreinfos.Where(t => t.ClassId == classInfo.Id).ToList();
                if (classscoreInfos.Count == 0)
                {
                    continue;
                }
                string[] data = GetClassScore(classscoreInfos);
                sb.Append("<tr>");

                sb.Append("<td>");
                sb.Append(num);
                sb.Append("</td>");

                sb.Append("<td class='text_left'>");
                sb.Append(classInfo.Name);
                sb.Append("</td>");

                sb.Append("<td>");
                sb.Append(classscoreInfos.Count);
                sb.Append("</td>");

                sb.Append("<td>");
                sb.Append(data[10]);
                sb.Append("</td>");

                sb.Append("<td>");
                sb.Append(data[4] + "(" + data[9] + "%)");
                sb.Append("</td>");

                sb.Append("<td>");
                sb.Append(data[3] + "(" + data[8] + "%)");
                sb.Append("</td>");

                sb.Append("<td>");
                sb.Append(data[2] + "(" + data[7] + "%)");
                sb.Append("</td>");

                sb.Append("<td>");
                sb.Append(data[1] + "(" + data[6] + "%)");
                sb.Append("</td>");

                sb.Append("<td>");
                sb.Append(data[0] + "(" + data[5] + "%)");
                sb.Append("</td>");
                sb.Append("</tr>");
                //表格二
                string[] levelData = GetLevelClass(classscoreInfos, goodNum, midNum, lowNum, endNum);
                gsb.Append("<tr>");
                gsb.Append("<td>");
                gsb.Append(num);
                gsb.Append("</td>");

                gsb.Append("<td>");
                gsb.Append(classInfo.Name);
                gsb.Append("</td>");

                gsb.Append("<td>");
                gsb.Append(classscoreInfos.Count);
                gsb.Append("</td>");

                gsb.Append("<td>");
                gsb.Append(data[10]);
                gsb.Append("</td>");

                gsb.Append("<td>");
                gsb.Append(levelData[0]);
                gsb.Append("</td>");

                gsb.Append("<td>");
                gsb.Append(levelData[1]);
                gsb.Append("</td>");

                gsb.Append("<td>");
                gsb.Append(levelData[2]);
                gsb.Append("</td>");

                gsb.Append("<td>");
                gsb.Append(levelData[3] + "%");
                gsb.Append("</td>");

                gsb.Append("<td>");
                gsb.Append(levelData[4]);
                gsb.Append("</td>");

                gsb.Append("<td>");
                gsb.Append(levelData[5] + "%");
                gsb.Append("</td>");

                gsb.Append("<td>");
                gsb.Append(levelData[6]);
                gsb.Append("</td>");

                gsb.Append("<td>");
                gsb.Append(levelData[7] + "%");
                gsb.Append("</td>");

                gsb.Append("<td>");
                gsb.Append(levelData[8]);
                gsb.Append("</td>");

                gsb.Append("<td>");
                gsb.Append(levelData[9] + "%");
                gsb.Append("</td>");
                gsb.Append("</tr>");
                Series baseSeries = new Series()
                {
                    Name = classInfo.Name,
                    ChartType = SeriesChartType.Spline,
                    XValueType = ChartValueType.Double,
                    BorderWidth = 2,
                    ChartArea = "ChartArea1"
                };
                baseSeries.Points.AddY(data[5]);
                baseSeries.Points.AddY(data[6]);
                baseSeries.Points.AddY(data[7]);
                baseSeries.Points.AddY(data[8]);
                baseSeries.Points.AddY(data[9]);
                Chart1.Series.Add(baseSeries);

                Series levelSeries = new Series()
                {
                    Name = classInfo.Name,
                    ChartType = SeriesChartType.StackedColumn,
                    Label = "班-" + num.ToString(),
                    LabelToolTip = classInfo.Name,
                };
                levelSeries["PointWidth"] = "0.4";
                levelSeries.Points.AddY(double.Parse(levelData[3]));
                levelSeries.Points.AddY(double.Parse(levelData[5]));
                levelSeries.Points.AddY(double.Parse(levelData[7]));
                levelSeries.Points.AddY(double.Parse(levelData[9]));
                Chart2.Series.Add(levelSeries);

                num++;
            }
            DataListBase.InnerHtml = sb.ToString();
            LevelDataListBase.InnerHtml = gsb.ToString();
        }
        private IList<int> GoodSchoolScoreSort(IList<StudentScoreExtendInfo> scoreInfos)
        {
            IList<int> result = new List<int>();
            scoreInfos = scoreInfos.OrderByDescending(t => t.CountScore).ToList();
            int num = Convert.ToInt32(scoreInfos.Count * 0.05);
            for (int i = 0; i < num; i++)
            {
                result.Add(scoreInfos[i].StudentId);
            }
            return result;
        }
        private IList<int> MidSchoolScoreSort(IList<StudentScoreExtendInfo> scoreInfos)
        {
            IList<int> result = new List<int>();
            scoreInfos = scoreInfos.OrderByDescending(t => t.CountScore).ToList();
            int star = Convert.ToInt32(scoreInfos.Count * 0.05);
            int end = Convert.ToInt32(scoreInfos.Count * 0.2);
            for (int i = star; i < end; i++)
            {
                result.Add(scoreInfos[i].StudentId);
            }
            return result;
        }
        private IList<int> LowSchoolScoreSort(IList<StudentScoreExtendInfo> scoreInfos)
        {
            IList<int> result = new List<int>();
            scoreInfos = scoreInfos.OrderBy(t => t.CountScore).ToList();
            int star = Convert.ToInt32(scoreInfos.Count * 0.05);
            int end = Convert.ToInt32(scoreInfos.Count * 0.2);
            for (int i = star; i < end; i++)
            {
                result.Add(scoreInfos[i].StudentId);
            }
            return result;
        }
        private IList<int> EndSchoolScoreSort(IList<StudentScoreExtendInfo> scoreInfos)
        {
            IList<int> result = new List<int>();
            scoreInfos = scoreInfos.OrderBy(t => t.CountScore).ToList();
            int num = Convert.ToInt32(scoreInfos.Count * 0.05);
            for (int i = 0; i < num; i++)
            {
                result.Add(scoreInfos[i].StudentId);
            }
            return result;
        }
        private string[] GetLevelClass(IList<StudentScoreExtendInfo> scoreInfos, IList<int> good, IList<int> mid, IList<int> low, IList<int> end)
        {
            int g = scoreInfos.Where(t => GetArray<int>.Get(good).Contains(t.StudentId)).Count();
            decimal max = scoreInfos.Max(t => t.CountScore);
            decimal min = scoreInfos.Min(t => t.CountScore);
            decimal g_percent = 0;
            if (g > 0)
                g_percent = Math.Round(decimal.Parse(g.ToString()) / decimal.Parse(scoreInfos.Count.ToString()) * 100, 1);
            int m = scoreInfos.Where(t => GetArray<int>.Get(mid).Contains(t.StudentId)).Count();
            decimal m_percent = 0;
            if (m > 0)
                m_percent = Math.Round(decimal.Parse(m.ToString()) / decimal.Parse(scoreInfos.Count.ToString()) * 100, 1);
            int l = scoreInfos.Where(t => GetArray<int>.Get(low).Contains(t.StudentId)).Count();
            decimal l_percent = 0;
            if (l > 0)
                l_percent = Math.Round(decimal.Parse(l.ToString()) / decimal.Parse(scoreInfos.Count.ToString()) * 100, 1);
            int e = scoreInfos.Where(t => GetArray<int>.Get(end).Contains(t.StudentId)).Count();
            decimal e_percent = 0;
            if (e > 0)
                e_percent = Math.Round(decimal.Parse(e.ToString()) / decimal.Parse(scoreInfos.Count.ToString()) * 100, 1);
            return new string[] { max.ToString(), min.ToString(), g.ToString(), g_percent.ToString(), m.ToString(), m_percent.ToString(), l.ToString(), l_percent.ToString(), e.ToString(), e_percent.ToString() };
        }
        private string[] GetClassScore(IList<StudentScoreExtendInfo> scoreInfos)
        {
            int score0 = 0, score1 = 0, score2 = 0, score3 = 0, score4 = 0;
            decimal percent0 = 0, percent1 = 0, percent2 = 0, percent3 = 0, percent4 = 0;
            decimal count = 0, avery = 0;
            foreach (StudentScoreExtendInfo info in scoreInfos)
            {
                count += info.CountScore;
                if (info.CountScore < 60)
                {
                    score0++;
                }
                if (info.CountScore >= 60 && info.CountScore <= 70)
                {
                    score1++;
                }
                if (info.CountScore > 70 && info.CountScore <= 80)
                {
                    score2++;
                }
                if (info.CountScore > 80 && info.CountScore <= 90)
                {
                    score3++;
                }
                if (info.CountScore > 90)
                {
                    score4++;
                }
            }
            avery = Math.Round(count / decimal.Parse(scoreInfos.Count.ToString()));
            if (score0 > 0)
            {
                percent0 = Math.Round(decimal.Parse(score0.ToString()) / decimal.Parse(scoreInfos.Count.ToString()) * 100, 1);
            }
            if (score1 > 0)
            {
                percent1 = Math.Round(decimal.Parse(score1.ToString()) / decimal.Parse(scoreInfos.Count.ToString()) * 100, 1);
            }
            if (score2 > 0)
            {
                percent2 = Math.Round(decimal.Parse(score2.ToString()) / decimal.Parse(scoreInfos.Count.ToString()) * 100, 1);
            }
            if (score3 > 0)
            {
                percent3 = Math.Round(decimal.Parse(score3.ToString()) / decimal.Parse(scoreInfos.Count.ToString()) * 100, 1);
            }
            if (score4 > 0)
            {
                percent4 = Math.Round(decimal.Parse(score4.ToString()) / decimal.Parse(scoreInfos.Count.ToString()) * 100, 1);
            }
            return new string[] { score0.ToString(), score1.ToString(), score2.ToString(), score3.ToString(), score4.ToString(), percent0.ToString(), percent1.ToString(), percent2.ToString(), percent3.ToString(), percent4.ToString(), avery.ToString() };
        }
        #endregion
        #region SchoolChartQuest
        private void SchoolChartQuest()
        {
            //IList<int> gradeIds = Grade.GetGradeIdBySchoolId(schoolid);
            //IList<TClassInfo> classInfos = TClass.GetClassInfoByGradeId(gradeIds);
            //IList<StudentScoreExtendInfo> studentscoreinfos = new List<StudentScoreExtendInfo>();
            //studentscoreinfos = StudentScoreExtend.GetList(examroomid, 0, schoolid, 0, 0, 0, 0, 0);
            //ExamRoomInfo examroomInfo = ExamRoom.GetSingleInfo(examroomid);
            if (examroomInfo == null)
                return;
            IList<QuestionInfo> listQuestion = SchoolChartQuestGetQuestion(examroomInfo.ExamPaperId);
            Chart3.ChartAreas["ChartArea1"].AxisX.Minimum = 1;
            Chart3.ChartAreas["ChartArea1"].AxisX.Maximum = listQuestion.Count;
            StringBuilder headerStr = new StringBuilder();
            headerStr.Append("<tr>");
            headerStr.Append("<th width='8%'>序号</th>");
            headerStr.Append("<th width='10%'>题型</th>");
            headerStr.Append("<th width='10%'>难度</th>");
            headerStr.Append("<th width='10%'>认知度</th>");
            headerStr.Append("<th width='10%'>区分度</th>");
            headerStr.Append("<th width='10%'>分值</th>");
            IList<int> classIds = new List<int>();
            foreach (TClassInfo classInfo in classInfos)
            {
                IList<StudentScoreExtendInfo> classscoreInfos = studentscoreinfos.Where(t => t.ClassId == classInfo.Id).ToList();
                if (classscoreInfos.Count == 0)
                {
                    continue;
                }
                classIds.Add(classInfo.Id);
                headerStr.Append("<th width='10%'>");
                headerStr.Append(classInfo.Name);
                headerStr.Append("</th>");
                Chart3.Series.Add(new Series()
                {
                    ChartType = SeriesChartType.Spline,
                    Name = "Class" + classInfo.Id.ToString(),
                    LegendText = classInfo.Name,
                    XValueType = ChartValueType.Double,
                    BorderWidth = 2,
                    ChartArea = "ChartArea1"
                });
            }
            headerStr.Append("</tr>");
            this.HeaderListQuest.InnerHtml = headerStr.ToString();
            int num = 1;
            StringBuilder bodyStr = new StringBuilder();
            foreach (QuestionInfo questInfo in listQuestion)
            {
                bodyStr.Append("<tr>");
                bodyStr.Append("<td>");
                bodyStr.Append(num.ToString());
                bodyStr.Append("</td>");

                string questTypeName = QuesType.GetQuesTypeInfoById(questInfo.QuesTypeId).Name;
                bodyStr.Append("<td>");
                bodyStr.Append(questTypeName);
                bodyStr.Append("</td>");

                string difficName = Diffic.GetDifficInfoById(questInfo.DifficId).Name;
                bodyStr.Append("<td>");
                bodyStr.Append(difficName);
                bodyStr.Append("</td>");

                string cognitiveName = CognitiveLevel.GetSingleInfo(questInfo.CognitiveLevelId).Name;
                bodyStr.Append("<td>");
                bodyStr.Append(cognitiveName);
                bodyStr.Append("</td>");

                bodyStr.Append("<td>");
                bodyStr.Append("");
                bodyStr.Append("</td>");

                bodyStr.Append("<td>");
                bodyStr.Append(questInfo.Score.ToString());
                bodyStr.Append("</td>");

                for (int i = 0; i < classIds.Count; i++)
                {
                    decimal result = SchoolChartQuestGetClassScore(studentscoreinfos, classIds[i], questInfo.Id, questInfo.Score);
                    bodyStr.Append("<td>");
                    bodyStr.Append(result + "%");
                    bodyStr.Append("</td>");
                    Chart3.Series["Class" + classIds[i].ToString()].Points.AddY(result);
                }
                bodyStr.Append("</tr>");
                num++;
            }
            this.DataListQuest.InnerHtml = bodyStr.ToString();
        }
        private decimal SchoolChartQuestGetClassScore(IList<StudentScoreExtendInfo> studentscoreinfos, int classId, int questId, decimal count)
        {
            decimal percent = 0;
            decimal score = 0;
            IList<StudentScoreExtendInfo> schoolscoreInfos = studentscoreinfos.Where(t => t.ClassId == classId).ToList();
            foreach (StudentScoreExtendInfo info in schoolscoreInfos)
            {
                IList<ScoreInfo> scoreInfos = ScoreHelper.GetScoreList(info.QuestItemScore);
                ScoreInfo scoreInfo = scoreInfos.Where(t => t.Id == questId).FirstOrDefault();
                if (scoreInfo != null && !PageValidate.IsEmpty(scoreInfo.Score))
                {
                    score += decimal.Parse(scoreInfo.Score);
                }
            }
            if (score > 0)
            {
                percent = Math.Round(score / (count * schoolscoreInfos.Count) * 100, 1);
            }
            return percent;
        }
        private IList<QuestionInfo> SchoolChartQuestGetQuestion(int exampaperid)
        {
            IList<QuestionInfo> resultInfos = new List<QuestionInfo>();
            ExamPaperInfo examPaperInfo = BAL.ExamPaper.GetT1(exampaperid);
            if (examPaperInfo.TestPaperPolicyMainId == null)
            {
                examPaperInfo.TestPaperPolicyMainId = 0;
            }
            IList<PaperQuestionInfo> infos = new List<PaperQuestionInfo>();
            infos = Question.GetList(exampaperid);
            IList<TestPaperPolicySubInfo> tpinfo = TestPaperPolicySub.GetList((int)examPaperInfo.TestPaperPolicyMainId);
            foreach (TestPaperPolicySubInfo info in tpinfo)
            {
                IList<PaperQuestionInfo> tInfos = infos.Where(t => t.SubPolicyId == info.Id).ToList();
                foreach (PaperQuestionInfo qinfo in tInfos)
                {
                    resultInfos.Add(Question.GetQuestionInfoById(qinfo.Id));
                }
            }
            return resultInfos;
        }
        #endregion
        #region SchoolChartKnowModle
        private void SchoolChartKnowModle()
        {
            //IList<int> gradeIds = Grade.GetGradeIdBySchoolId(schoolid);
            //IList<TClassInfo> classInfos = TClass.GetClassInfoByGradeId(gradeIds);
            //IList<StudentScoreExtendInfo> studentscoreinfos = new List<StudentScoreExtendInfo>();
            //studentscoreinfos = StudentScoreExtend.GetList(examroomid, 0, schoolid, 0, 0, 0, 0, 0);
            //ExamRoomInfo examroomInfo = ExamRoom.GetSingleInfo(examroomid);
            if (examroomInfo == null)
                return;
            IList<KnowledgeInfo> knowInfos = SchoolChartKnowModleGetKnowledgeMode(examroomInfo.SubjectId);

            IList<QuestionInfo> listQuestion = SchoolChartKnowModleGetQuestion(examroomInfo.ExamPaperId);

            StringBuilder headerStr = new StringBuilder();
            headerStr.Append("<tr>");
            headerStr.Append("<th width='15%'>知识领域</th>");
            headerStr.Append("<th width='8%'>分值</th>");
            IList<int> classIds = new List<int>();
            foreach (TClassInfo classInfo in classInfos)
            {
                IList<StudentScoreExtendInfo> classscoreInfos = studentscoreinfos.Where(t => t.ClassId == classInfo.Id).ToList();
                if (classscoreInfos.Count == 0)
                {
                    continue;
                }
                classIds.Add(classInfo.Id);
                headerStr.Append("<th width='10%'>");
                headerStr.Append(classInfo.Name);
                headerStr.Append("</th>");
                Chart4.Series.Add(new Series()
                {
                    ChartType = SeriesChartType.Spline,
                    Name = "Class" + classInfo.Id.ToString(),
                    LegendText = classInfo.Name,
                    XValueType = ChartValueType.Double,
                    BorderWidth = 2,
                    ChartArea = "ChartArea1"
                });
            }
            headerStr.Append("<th width='10%'>评价结果</th>");
            headerStr.Append("<th width='10%'>教学见意</th>");
            headerStr.Append("</tr>");
            this.HeaderListKnowModle.InnerHtml = headerStr.ToString();
            double v = 0.5, s = 1.5;
            StringBuilder bodyStr = new StringBuilder();
            foreach (KnowledgeInfo know in knowInfos)
            {
                decimal questScoreCount = 0;
                IList<int> questIds = new List<int>();
                foreach (QuestionInfo quest in listQuestion)
                {
                    if (quest.KnowId == know.Id)
                    {
                        questScoreCount += quest.Score;
                        questIds.Add(quest.Id);
                    }
                    else if (know.ChildKnowledgeInfos.Count > 0)
                    {
                        IList<int> ids = know.ChildKnowledgeInfos.Select(t => t.Id).ToList();
                        if (GetArray<int>.Get(ids).Contains(quest.KnowId))
                        {
                            questScoreCount += quest.Score;
                            questIds.Add(quest.Id);
                        }
                        else
                        {
                            foreach (KnowledgeInfo n in know.ChildKnowledgeInfos)
                            {
                                if (n.ChildKnowledgeInfos.Count > 0)
                                {
                                    IList<int> childids = n.ChildKnowledgeInfos.Select(t => t.Id).ToList();
                                    if (GetArray<int>.Get(childids).Contains(quest.KnowId))
                                    {
                                        questScoreCount += quest.Score;
                                        questIds.Add(quest.Id);
                                    }
                                }
                            }
                        }
                    }
                }
                if (questIds.Count == 0)
                {
                    continue;
                }
                Chart4.ChartAreas["ChartArea1"].AxisX.CustomLabels.Add(new CustomLabel()
                {
                    Text = know.Name,
                    FromPosition = v,
                    ToPosition = s
                });
                v = v + 1;
                s = s + 1;
                bodyStr.Append("<tr>");
                bodyStr.Append("<td class='text_left'>");
                bodyStr.Append(know.Name);
                bodyStr.Append("</td>");
                bodyStr.Append("<td>");
                bodyStr.Append(questScoreCount);
                bodyStr.Append("</td>");
                for (int i = 0; i < classIds.Count; i++)
                {
                    decimal result = SchoolChartKnowModleGetClassScore(studentscoreinfos, classIds[i], questIds, questScoreCount);
                    bodyStr.Append("<td>");
                    bodyStr.Append(result + "%");
                    bodyStr.Append("</td>");
                    Chart4.Series["Class" + classIds[i].ToString()].Points.AddY(result);
                }
                bodyStr.Append("<td>");
                bodyStr.Append("&nbsp;");
                bodyStr.Append("</td>");
                bodyStr.Append("<td>");
                bodyStr.Append("&nbsp;");
                bodyStr.Append("</td>");
                bodyStr.Append("</tr>");
            }
            this.DataListKnowModle.InnerHtml = bodyStr.ToString();
        }
        private decimal SchoolChartKnowModleGetClassScore(IList<StudentScoreExtendInfo> studentscoreinfos, int classid, IList<int> questIds, decimal count)
        {
            decimal percent = 0;
            decimal score = 0;
            IList<StudentScoreExtendInfo> schoolscoreInfos = studentscoreinfos.Where(t => t.ClassId == classid).ToList();
            foreach (StudentScoreExtendInfo info in schoolscoreInfos)
            {
                IList<ScoreInfo> scoreInfos = ScoreHelper.GetScoreList(info.QuestItemScore);
                scoreInfos = scoreInfos.Where(t => GetArray<int>.Get(questIds).Contains(t.Id)).ToList();
                foreach (ScoreInfo scoreInfo in scoreInfos)
                {
                    if (!PageValidate.IsEmpty(scoreInfo.Score))
                    {
                        score += decimal.Parse(scoreInfo.Score);
                    }
                }
            }
            if (score > 0)
            {
                percent = Math.Round(score / (count * schoolscoreInfos.Count) * 100, 1);
            }
            return percent;
        }
        private IList<KnowledgeInfo> SchoolChartKnowModleGetKnowledgeMode(int subjectid)
        {
            IList<KnowledgeInfo> infos = new List<KnowledgeInfo>();
            infos = Knowledge.GetKnowledgeInfosBySubjectId(subjectid).Where(t => t.Keyword.Length == 1).ToList();
            foreach (KnowledgeInfo info in infos)
            {
                info.ChildKnowledgeInfos = Knowledge.GetKnowledgeInfos(info.Id);
                foreach (KnowledgeInfo subInfo in info.ChildKnowledgeInfos)
                {
                    subInfo.ChildKnowledgeInfos = Knowledge.GetKnowledgeInfos(subInfo.Id);
                }
            }
            return infos;
        }
        private IList<QuestionInfo> SchoolChartKnowModleGetQuestion(int exampaperid)
        {
            IList<QuestionInfo> infos = new List<QuestionInfo>();
            infos = Question.GetQuestions(exampaperid, "", "", "", "", "", "", "", "", "", 0, 0);
            return infos;
        }
        #endregion
        #region SchoolChartKnowPoint
        private void SchoolChartKnowPoint()
        {
            //IList<int> gradeIds = Grade.GetGradeIdBySchoolId(schoolid);
            //IList<TClassInfo> classInfos = TClass.GetClassInfoByGradeId(gradeIds);
            //IList<StudentScoreExtendInfo> studentscoreinfos = new List<StudentScoreExtendInfo>();
            //studentscoreinfos = StudentScoreExtend.GetList(examroomid, 0, schoolid, 0, 0, 0, 0, 0);
            //ExamRoomInfo examroomInfo = ExamRoom.GetSingleInfo(examroomid);
            if (examroomInfo == null)
                return;
            IList<KnowledgeInfo> knowInfos = SchoolChartKnowPointGetKnowledgeMode(examroomInfo.SubjectId);

            IList<QuestionInfo> listQuestion = SchoolChartKnowPointGetQuestion(examroomInfo.ExamPaperId);

            StringBuilder headerStr = new StringBuilder();
            headerStr.Append("<tr>");
            headerStr.Append("<th width='5%'>序号</th>");
            headerStr.Append("<th width='15%'>考察点</th>");
            IList<int> classIds = new List<int>();
            foreach (TClassInfo classInfo in classInfos)
            {
                IList<StudentScoreExtendInfo> classscoreInfos = studentscoreinfos.Where(t => t.ClassId == classInfo.Id).ToList();
                if (classscoreInfos.Count == 0)
                {
                    continue;
                }
                classIds.Add(classInfo.Id);
                headerStr.Append("<th width='10%'>");
                headerStr.Append(classInfo.Name);
                headerStr.Append("</th>");
                Chart5.Series.Add(new Series()
                {
                    ChartType = SeriesChartType.Spline,
                    Name = "Class" + classInfo.Id.ToString(),
                    LegendText = classInfo.Name,
                    XValueType = ChartValueType.Double,
                    BorderWidth = 2,
                    ChartArea = "ChartArea1"
                });
            }
            headerStr.Append("</tr>");
            this.HeaderListKnowPoint.InnerHtml = headerStr.ToString();
            int asc = 65;
            double v = 0.5, s = 1.5;
            StringBuilder bodyStr = new StringBuilder();
            foreach (KnowledgeInfo know in knowInfos)
            {
                decimal questScoreCount = 0;
                IList<int> questIds = new List<int>();
                foreach (QuestionInfo quest in listQuestion)
                {
                    if (quest.KnowId == know.Id)
                    {
                        questScoreCount += quest.Score;
                        questIds.Add(quest.Id);

                    }
                    else if (know.ParentKnowledgeInfo != null)
                    {
                        if (know.ParentKnowledgeInfo.Id == quest.KnowId)
                        {
                            questScoreCount += quest.Score;
                            questIds.Add(quest.Id);
                        }
                        else if (know.ParentKnowledgeInfo.ParentKnowledgeInfo != null)
                        {

                            if (know.ParentKnowledgeInfo.ParentKnowledgeInfo.Id == quest.KnowId)
                            {
                                questScoreCount += quest.Score;
                                questIds.Add(quest.Id);
                            }
                        }
                    }
                }
                if (questIds.Count == 0)
                {
                    continue;
                }
                string numStr = Utility.AscToChr(asc);
                Chart5.ChartAreas["ChartArea1"].AxisX.CustomLabels.Add(new CustomLabel()
                {
                    Text = numStr,
                    FromPosition = v,
                    ToPosition = s
                });
                v = v + 1;
                s = s + 1;
                bodyStr.Append("<tr>");
                bodyStr.Append("<td>");
                bodyStr.Append(numStr);
                bodyStr.Append("</td>");
                bodyStr.Append("<td class='text_left'>");
                bodyStr.Append(know.Name);
                bodyStr.Append("</td>");
                for (int i = 0; i < classIds.Count; i++)
                {
                    decimal result = SchoolChartKnowPointGetClassScore(studentscoreinfos, classIds[i], questIds, questScoreCount);
                    bodyStr.Append("<td>");
                    bodyStr.Append(result + "%");
                    bodyStr.Append("</td>");
                    Chart5.Series["Class" + classIds[i].ToString()].Points.AddY(result);
                }
                bodyStr.Append("</tr>");
                asc++;
            }
            this.DataListKnowPoint.InnerHtml = bodyStr.ToString();
        }
        private decimal SchoolChartKnowPointGetClassScore(IList<StudentScoreExtendInfo> studentscoreinfos, int classId, IList<int> questIds, decimal count)
        {
            decimal percent = 0;
            decimal score = 0;
            IList<StudentScoreExtendInfo> schoolscoreInfos = studentscoreinfos.Where(t => t.ClassId == classId).ToList();
            foreach (StudentScoreExtendInfo info in schoolscoreInfos)
            {
                IList<ScoreInfo> scoreInfos = ScoreHelper.GetScoreList(info.QuestItemScore);
                scoreInfos = scoreInfos.Where(t => GetArray<int>.Get(questIds).Contains(t.Id)).ToList();
                foreach (ScoreInfo scoreInfo in scoreInfos)
                {
                    if (!PageValidate.IsEmpty(scoreInfo.Score))
                    {
                        score += decimal.Parse(scoreInfo.Score);
                    }
                }
            }
            if (score > 0)
            {
                percent = Math.Round(score / (count * schoolscoreInfos.Count) * 100, 1);
            }
            return percent;
        }
        private IList<KnowledgeInfo> SchoolChartKnowPointGetKnowledgeMode(int subjectid)
        {
            IList<KnowledgeInfo> infos = new List<KnowledgeInfo>();
            infos = Knowledge.GetKnowledgeInfosBySubjectId(subjectid).Where(t => t.Keyword.Length == 5).ToList();
            foreach (KnowledgeInfo info in infos)
            {
                info.ParentKnowledgeInfo = Knowledge.GetKnowledgeInfo(info);
                if (info.ParentKnowledgeInfo != null)
                {
                    info.ParentKnowledgeInfo.ParentKnowledgeInfo = Knowledge.GetKnowledgeInfo(info.ParentKnowledgeInfo);

                }
            }
            return infos;
        }
        private IList<QuestionInfo> SchoolChartKnowPointGetQuestion(int exampaperid)
        {
            IList<QuestionInfo> infos = new List<QuestionInfo>();
            infos = Question.GetQuestions(exampaperid, "", "", "", "", "", "", "", "", "", 0, 0);
            return infos;
        }
        #endregion
        #region SchoolChartCongitive
        private void SchoolChartCongitive()
        {
            //IList<int> gradeIds = Grade.GetGradeIdBySchoolId(schoolid);
            //IList<TClassInfo> classInfos = TClass.GetClassInfoByGradeId(gradeIds);
            //IList<StudentScoreExtendInfo> studentscoreinfos = new List<StudentScoreExtendInfo>();
            //studentscoreinfos = StudentScoreExtend.GetList(examroomid, 0, schoolid, 0, 0, 0, 0, 0);
            //ExamRoomInfo examroomInfo = ExamRoom.GetSingleInfo(examroomid);
            if (examroomInfo == null)
                return;
            IList<CognitiveLevelInfo> listCognitiveLevel = SchoolChartCongitiveGetCognitiveLeve();
            IList<QuestionInfo> listQuestion = SchoolChartCongitiveGetQuestion(examroomInfo.ExamPaperId);

            StringBuilder headerStr = new StringBuilder();
            headerStr.Append("<tr>");
            headerStr.Append("<th width='15%'>认识能力</th>");
            IList<int> classIds = new List<int>();
            foreach (TClassInfo classInfo in classInfos)
            {
                IList<StudentScoreExtendInfo> classscoreInfos = studentscoreinfos.Where(t => t.ClassId == classInfo.Id).ToList();
                if (classscoreInfos.Count == 0)
                {
                    continue;
                }
                classIds.Add(classInfo.Id);
                headerStr.Append("<th width='10%'>");
                headerStr.Append(classInfo.Name);
                headerStr.Append("</th>");
                Chart6.Series.Add(new Series()
                {
                    ChartType = SeriesChartType.Spline,
                    Name = "Class" + classInfo.Id.ToString(),
                    LegendText = classInfo.Name,
                    XValueType = ChartValueType.Double,
                    BorderWidth = 2,
                    ChartArea = "ChartArea1"
                });
            }
            headerStr.Append("</tr>");
            this.HeaderListCongitive.InnerHtml = headerStr.ToString();

            double v = 0.5, s = 1.5;
            StringBuilder bodyStr = new StringBuilder();
            foreach (CognitiveLevelInfo cognitive in listCognitiveLevel)
            {
                decimal questScoreCount = 0;
                IList<int> questIds = new List<int>();
                foreach (QuestionInfo quest in listQuestion)
                {
                    if (quest.CognitiveLevelId == cognitive.Id)
                    {
                        questScoreCount += quest.Score;
                        questIds.Add(quest.Id);

                    }
                }
                if (questIds.Count == 0)
                {
                    continue;
                }
                Chart6.ChartAreas["ChartArea1"].AxisX.CustomLabels.Add(new CustomLabel()
                {
                    Text = cognitive.Name,
                    FromPosition = v,
                    ToPosition = s
                });
                v = v + 1;
                s = s + 1;
                bodyStr.Append("<tr>");
                bodyStr.Append("<td class='text_left'>");
                bodyStr.Append(cognitive.Name);
                bodyStr.Append("</td>");
                for (int i = 0; i < classIds.Count; i++)
                {
                    decimal result = SchoolChartCongitiveGetClassScore(studentscoreinfos, classIds[i], questIds, questScoreCount);
                    bodyStr.Append("<td>");
                    bodyStr.Append(result + "%");
                    bodyStr.Append("</td>");
                    Chart6.Series["Class" + classIds[i].ToString()].Points.AddY(result);
                }
                bodyStr.Append("</tr>");
            }
            this.DataListCongitive.InnerHtml = bodyStr.ToString();
        }
        private decimal SchoolChartCongitiveGetClassScore(IList<StudentScoreExtendInfo> studentscoreinfos, int classId, IList<int> questIds, decimal count)
        {
            decimal percent = 0;
            decimal score = 0;
            IList<StudentScoreExtendInfo> schoolscoreInfos = studentscoreinfos.Where(t => t.ClassId == classId).ToList();
            foreach (StudentScoreExtendInfo info in schoolscoreInfos)
            {
                IList<ScoreInfo> scoreInfos = ScoreHelper.GetScoreList(info.QuestItemScore);
                scoreInfos = scoreInfos.Where(t => GetArray<int>.Get(questIds).Contains(t.Id)).ToList();
                foreach (ScoreInfo scoreInfo in scoreInfos)
                {
                    if (!PageValidate.IsEmpty(scoreInfo.Score))
                    {
                        score += decimal.Parse(scoreInfo.Score);
                    }
                }
            }
            if (score > 0)
            {
                percent = Math.Round(score / (count * schoolscoreInfos.Count) * 100, 1);
            }
            return percent;
        }
        private IList<CognitiveLevelInfo> SchoolChartCongitiveGetCognitiveLeve()
        {
            IList<CognitiveLevelInfo> infos = new List<CognitiveLevelInfo>();
            infos = CognitiveLevel.GetList(0);
            return infos;
        }
        private IList<QuestionInfo> SchoolChartCongitiveGetQuestion(int exampaperid)
        {
            IList<QuestionInfo> infos = new List<QuestionInfo>();
            infos = Question.GetQuestions(exampaperid, "", "", "", "", "", "", "", "", "", 0, 0);
            return infos;
        }
        #endregion
        #region SchoolChartQuestType
        private void SchoolChartQuestType()
        {//IList<int> gradeIds = Grade.GetGradeIdBySchoolId(schoolid);
            //IList<TClassInfo> classInfos = TClass.GetClassInfoByGradeId(gradeIds);
            //IList<StudentScoreExtendInfo> studentscoreinfos = new List<StudentScoreExtendInfo>();
            //studentscoreinfos = StudentScoreExtend.GetList(examroomid, 0, schoolid, 0, 0, 0, 0, 0);
            //ExamRoomInfo examroomInfo = ExamRoom.GetSingleInfo(examroomid);
            if (examroomInfo == null)
                return;
            IList<QuesTypeInfo> listQuestType = SchoolChartQuestTypeGetQuestType();
            IList<QuestionInfo> listQuestion = SchoolChartQuestTypeGetQuestion(examroomInfo.ExamPaperId);

            StringBuilder headerStr = new StringBuilder();
            headerStr.Append("<tr>");
            headerStr.Append("<th width='15%'>题型</th>");
            IList<int> classIds = new List<int>();
            foreach (TClassInfo classInfo in classInfos)
            {
                IList<StudentScoreExtendInfo> classscoreInfos = studentscoreinfos.Where(t => t.ClassId == classInfo.Id).ToList();
                if (classscoreInfos.Count == 0)
                {
                    continue;
                }
                classIds.Add(classInfo.Id);
                headerStr.Append("<th width='10%'>");
                headerStr.Append(classInfo.Name);
                headerStr.Append("</th>");
                Chart7.Series.Add(new Series()
                {
                    ChartType = SeriesChartType.Spline,
                    Name = "Class" + classInfo.Id.ToString(),
                    LegendText = classInfo.Name,
                    XValueType = ChartValueType.Double,
                    BorderWidth = 2,
                    ChartArea = "ChartArea1"
                });
            }
            headerStr.Append("</tr>");
            this.HeaderListQuestType.InnerHtml = headerStr.ToString();
            double v = 0.5, s = 1.5;
            StringBuilder bodyStr = new StringBuilder();
            foreach (QuesTypeInfo questype in listQuestType)
            {
                decimal questScoreCount = 0;
                IList<int> questIds = new List<int>();
                foreach (QuestionInfo quest in listQuestion)
                {
                    if (quest.QuesTypeId == questype.Id)
                    {
                        questScoreCount += quest.Score;
                        questIds.Add(quest.Id);
                    }
                }
                if (questIds.Count == 0)
                {
                    continue;
                }
                Chart7.ChartAreas["ChartArea1"].AxisX.CustomLabels.Add(new CustomLabel()
                {
                    Text = questype.Name,
                    FromPosition = v,
                    ToPosition = s
                });
                v = v + 1;
                s = s + 1;
                bodyStr.Append("<tr>");
                bodyStr.Append("<td class='text_left'>");
                bodyStr.Append(questype.Name);
                bodyStr.Append("</td>");
                for (int i = 0; i < classIds.Count; i++)
                {
                    decimal result = SchoolChartQuestTypeGetClassScore(studentscoreinfos, classIds[i], questIds, questScoreCount);
                    bodyStr.Append("<td>");
                    bodyStr.Append(result + "%");
                    bodyStr.Append("</td>");
                    Chart7.Series["Class" + classIds[i].ToString()].Points.AddY(result);
                }
                bodyStr.Append("</tr>");
            }
            this.DataListQuestType.InnerHtml = bodyStr.ToString();
        }
        private decimal SchoolChartQuestTypeGetClassScore(IList<StudentScoreExtendInfo> studentscoreinfos, int classId, IList<int> questIds, decimal count)
        {
            decimal percent = 0;
            decimal score = 0;
            IList<StudentScoreExtendInfo> schoolscoreInfos = studentscoreinfos.Where(t => t.ClassId == classId).ToList();
            foreach (StudentScoreExtendInfo info in schoolscoreInfos)
            {
                IList<ScoreInfo> scoreInfos = ScoreHelper.GetScoreList(info.QuestItemScore);
                scoreInfos = scoreInfos.Where(t => GetArray<int>.Get(questIds).Contains(t.Id)).ToList();
                foreach (ScoreInfo scoreInfo in scoreInfos)
                {
                    if (!PageValidate.IsEmpty(scoreInfo.Score))
                    {
                        score += decimal.Parse(scoreInfo.Score);
                    }
                }
            }
            if (score > 0)
            {
                percent = Math.Round(score / (count * schoolscoreInfos.Count) * 100, 1);
            }
            return percent;
        }
        private IList<QuesTypeInfo> SchoolChartQuestTypeGetQuestType()
        {
            IList<QuesTypeInfo> infos = new List<QuesTypeInfo>();
            infos = QuesType.GetQuesTypeInfos(0, 0);
            return infos;
        }
        private IList<QuestionInfo> SchoolChartQuestTypeGetQuestion(int exampaperid)
        {
            IList<QuestionInfo> infos = new List<QuestionInfo>();
            infos = Question.GetQuestions(exampaperid, "", "", "", "", "", "", "", "", "", 0, 0);
            return infos;
        }
        #endregion
        #region SchoolChartDiffic
        private void SchoolChartDiffic()
        {
            //IList<int> gradeIds = Grade.GetGradeIdBySchoolId(schoolid);
            //IList<TClassInfo> classInfos = TClass.GetClassInfoByGradeId(gradeIds);
            //IList<StudentScoreExtendInfo> studentscoreinfos = new List<StudentScoreExtendInfo>();
            //studentscoreinfos = StudentScoreExtend.GetList(examroomid, 0, schoolid, 0, 0, 0, 0, 0);
            //ExamRoomInfo examroomInfo = ExamRoom.GetSingleInfo(examroomid);
            if (examroomInfo == null)
                return;
            IList<DifficInfo> listDiffic = SchoolChartDifficGetDiffic();
            IList<QuestionInfo> listQuestion = SchoolChartDifficGetQuestion(examroomInfo.ExamPaperId);

            StringBuilder headerStr = new StringBuilder();
            headerStr.Append("<tr>");
            headerStr.Append("<th width='15%'>试题难度</th>");
            IList<int> classIds = new List<int>();
            foreach (TClassInfo classInfo in classInfos)
            {
                IList<StudentScoreExtendInfo> classscoreInfos = studentscoreinfos.Where(t => t.ClassId == classInfo.Id).ToList();
                if (classscoreInfos.Count == 0)
                {
                    continue;
                }
                classIds.Add(classInfo.Id);
                headerStr.Append("<th width='10%'>");
                headerStr.Append(classInfo.Name);
                headerStr.Append("</th>");
                Chart8.Series.Add(new Series()
                {
                    ChartType = SeriesChartType.Spline,
                    Name = "Class" + classInfo.Id.ToString(),
                    LegendText = classInfo.Name,
                    XValueType = ChartValueType.Double,
                    BorderWidth = 2,
                    ChartArea = "ChartArea1"
                });
            }
            headerStr.Append("</tr>");
            this.HeaderListDiffic.InnerHtml = headerStr.ToString();
            double v = 0.5, s = 1.5;
            StringBuilder bodyStr = new StringBuilder();
            foreach (DifficInfo diffic in listDiffic)
            {
                decimal questScoreCount = 0;
                IList<int> questIds = new List<int>();
                foreach (QuestionInfo quest in listQuestion)
                {
                    if (quest.DifficId == diffic.Id)
                    {
                        questScoreCount += quest.Score;
                        questIds.Add(quest.Id);
                    }
                }
                if (questIds.Count == 0)
                {
                    continue;
                }
                Chart8.ChartAreas["ChartArea1"].AxisX.CustomLabels.Add(new CustomLabel()
                {
                    Text = diffic.Name,
                    FromPosition = v,
                    ToPosition = s
                });
                v = v + 1;
                s = s + 1;
                bodyStr.Append("<tr>");
                bodyStr.Append("<td class='text_left'>");
                bodyStr.Append(diffic.Name);
                bodyStr.Append("</td>");
                for (int i = 0; i < classIds.Count; i++)
                {
                    decimal result = SchoolChartDifficGetClassScore(studentscoreinfos, classIds[i], questIds, questScoreCount);
                    bodyStr.Append("<td>");
                    bodyStr.Append(result + "%");
                    bodyStr.Append("</td>");
                    Chart8.Series["Class" + classIds[i].ToString()].Points.AddY(result);
                }
                bodyStr.Append("</tr>");
            }
            this.DataListDiffic.InnerHtml = bodyStr.ToString();
        }
        private decimal SchoolChartDifficGetClassScore(IList<StudentScoreExtendInfo> studentscoreinfos, int classId, IList<int> questIds, decimal count)
        {
            decimal percent = 0;
            decimal score = 0;
            IList<StudentScoreExtendInfo> schoolscoreInfos = studentscoreinfos.Where(t => t.ClassId == classId).ToList();
            foreach (StudentScoreExtendInfo info in schoolscoreInfos)
            {
                IList<ScoreInfo> scoreInfos = ScoreHelper.GetScoreList(info.QuestItemScore);
                scoreInfos = scoreInfos.Where(t => GetArray<int>.Get(questIds).Contains(t.Id)).ToList();
                foreach (ScoreInfo scoreInfo in scoreInfos)
                {
                    if (!PageValidate.IsEmpty(scoreInfo.Score))
                    {
                        score += decimal.Parse(scoreInfo.Score);
                    }
                }
            }
            if (score > 0)
            {
                percent = Math.Round(score / (count * schoolscoreInfos.Count) * 100, 1);
            }
            return percent;
        }
        private IList<DifficInfo> SchoolChartDifficGetDiffic()
        {
            IList<DifficInfo> infos = new List<DifficInfo>();
            infos = Diffic.GetDifficInfos(0, 0);
            return infos;
        }
        private IList<QuestionInfo> SchoolChartDifficGetQuestion(int exampaperid)
        {
            IList<QuestionInfo> infos = new List<QuestionInfo>();
            infos = Question.GetQuestions(exampaperid, "", "", "", "", "", "", "", "", "", 0, 0);
            return infos;
        }
        #endregion
        #region SchoolChartAnswer
        ExamPaperInfo ExamPaper_Info =  new ExamPaperInfo();
        private void SchoolChartAnswer()
        {
            ExamPaper_Info = BAL.ExamPaper.GetT1(examroomInfo.ExamPaperId);
            LoadQuestion(examroomInfo.ExamPaperId);
        }
        private void LoadQuestion(int exampaperid)
        {
            string[] hanzi = new string[] { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "二十一", "二十二", "二十三", "二十四", "二十五", "二十六", "二十七", "二十八", "二十九", "三十" };
            IList<PaperQuestionInfo> infos = new List<PaperQuestionInfo>();
            infos = Question.GetList(exampaperid);
            if (ExamPaper_Info.TestPaperPolicyMainId == null)
            {
                ExamPaper_Info.TestPaperPolicyMainId = 0;
            }
            IList<TestPaperPolicySubInfo> tpinfo = TestPaperPolicySub.GetList((int)ExamPaper_Info.TestPaperPolicyMainId);
            StringBuilder sb = new StringBuilder();
            int i = 0;
            int a = 1;
            foreach (TestPaperPolicySubInfo info in tpinfo)
            {
                XmlQuestion xq = XmlQuestionHelper.GetXmlQuestionInfo(info.Content);
                sb.Append("<h3>");
                sb.Append(hanzi[i]);
                sb.Append("、");
                sb.Append(QuesType.GetQuesTypeInfoById(int.Parse(xq.Type)).Name);
                sb.Append("共 ");
                sb.Append(xq.AllCount.ToString());
                sb.Append(" 小题 ");
                if (xq.SingleScore != null && xq.SingleScore.Count > 0)
                {
                    sb.Append("每小题 ");
                    sb.Append(string.Join(",", ArrayHelper.ConvertToStringArray(GetArray<decimal>.Get(xq.SingleScore))));
                    sb.Append(" 分");
                }
                sb.Append("总分为：");
                sb.Append(xq.AllScore.ToString());
                sb.Append("分");
                sb.Append("</h3>");
                IList<PaperQuestionInfo> tInfos = infos.Where(t => t.SubPolicyId == info.Id).ToList();
                foreach (PaperQuestionInfo qinfo in tInfos)
                {
                    sb.Append("<div class='block'>");
                    sb.Append("<span class='num'>" + a.ToString() + "、</span>");
                    sb.Append("<div class='content'>");
                    qinfo.Title = ClearHtml(qinfo.Title);
                    if (xq.SingleScore.Count > 1)
                    {
                        qinfo.Title = WiterScore(qinfo.Title, qinfo.Score);
                    }
                    sb.Append(qinfo.Title);
                    sb.Append("</div>");
                    sb.Append("<div class='answer'><span class='num'>参考答案：</span>");
                    sb.Append("<div class='content'>");
                    sb.Append(qinfo.Answer);
                    sb.Append("</div></div>");
                    sb.Append("<div class='isclear'></div></div>");
                    a++;
                }
                i++;
            }
            TempListAnswer.InnerHtml = sb.ToString();
        }
        private string WiterScore(string InputStr, decimal Score)
        {
            string t = InputStr;
            string[] strArray = new Regex("<.[^>]*?>(.*?)</.*?>", RegexOptions.IgnoreCase).Split(t);
            foreach (string item in strArray)
            {
                string temp = CodingHtml(item);
                temp = Regex.Replace(temp, "{{.*?}}", "");
                if (temp.Trim().Length > 0)
                {
                    if (!temp.Trim().StartsWith("{{"))
                    {
                        if (t.IndexOf(temp.Trim()) > -1)
                        {
                            t = t.Replace(temp, "(" + Score.ToString() + ")" + temp);
                            return t;
                        }
                    }
                }
            }
            return t;
        }
        private string CodingHtml(string InputStr)
        {
            if (InputStr.Length > 0)
            {
                string t = InputStr;
                t = t.Replace("&nbsp;", "{{空格}}");
                t = Regex.Replace(t, "<(.*?)>", "{{($1)}}");
                return t;
            }
            else
            {
                return InputStr;
            }
        }
        private string DecodingHtml(string InputStr)
        {
            if (InputStr.Length > 0)
            {
                string t = InputStr;
                t = t.Replace("{{空格}}", "&nbsp;");
                t = Regex.Replace(t, "{{(.*?)}}", "<$1>");
                return t;
            }
            else
            {
                return InputStr;
            }
        }
        private string ClearHtml(string InputStr)
        {
            string Temp = Module_String.clearhtml(InputStr, "span");
            Temp = Temp.Replace("<p>&nbsp;</p>", "");
            Temp = Module_String.DelStr("style=\"", "\"", Temp);
            Temp = Module_String.DelStr("class=\"", "\"", Temp);
            return Temp;
        }
        #endregion
    }
}